window10

您所在的位置:网站首页 docker 使用宿主机ip window10

window10

#window10| 来源: 网络整理| 查看: 265

背景

最近在win10上面折腾docker, 由于机器没有分配固定的IP地址,每次重启之后IP地址都会变化,每次调试都需要改配置,非常麻烦 :(

 

解决

查看本机hosts文件 (C:\Windows\System32\drivers\etc\hosts),发现在安装 docker desktop后, docker已经为配置了默认的子网和gatewa,具体如下:

# Added by Docker Desktop 139.24.227.29 host.docker.internal 139.24.227.29 gateway.docker.internal # To allow the same kube context to work on the host and the container: 127.0.0.1 kubernetes.docker.internal # End of section

 

可以看到,139.24.227.29 的 IP 地址已经被docker 所使用,因此,我们就可以使用这个IP作为固定的IP配置,供docker continer 之间通信使用。 

本机 docker container 之外的app, 可以使用 127.0.0.1

 

(完)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3